#pragma once

#include "CBrushSpan.h"
#include "CMILMatrix.h"

struct GENCOLORSDATA;


typedef void (__stdcall *PFNGenerateColors)(GENCOLORSDATA *);
typedef void (__stdcall *PFNGenerateOpacityMask)(GENCOLORSDATA *);

class CImageSpan :
	public CBrushSpan
{

public: 
	CImageSpan();
	virtual ~CImageSpan();
	enum PixelFormat GetPixelFormat();
	virtual HRESULT SetBrush(const CMILMatrix * pWorldTransform, const struct XRECTF_WH * pBrushBounds, CBrush * pBrush);
	virtual XINT32 SolidColor(XUINT32 nCPUCore, XINT32 nY, XUINT32 * pPargb);
	virtual void GenerateColors(struct GENCOLORSDATA * pGCD);
	virtual XINT32 IsZeroAlpha();
	virtual XINT32 IsOpaque();
protected: 
	XINT32 ComputeTextureX(XINT32 nX, XINT32 nY);
	XINT32 ComputeTextureY(XINT32 nX, XINT32 nY);
	void SetImageParameters(struct GENCOLORSDATA * pGCD);
	XUINT32 m_nWidth;
	XUINT32 m_nHeight;
	XINT32 m_nStride;
	XINT32 m_nTextureFixed16Dx;
	XINT32 m_nTextureFixed16Dy;
	XINT32 m_nTextureFixed16DownDx;
	XINT32 m_nTextureFixed16DownDy;
	XINT32 m_nTextureFixed16StartX;
	XINT32 m_nTextureFixed16StartY;
	XINT32 m_nTextureSimpleDx;
	XINT32 m_nTextureSimpleDy;
	enum PixelFormat m_PixelFormat;
	XUINT32 m_bOpaque:1;
	struct XRECTF_WH m_rcBounds;
protected: 
	CMILMatrix m_matDeviceToSource; 
	struct IPALSurface * m_pImageSurface;
	PFNGenerateColors  * m_pfnGenerateColors;
	PFNGenerateOpacityMask  * m_pfnGenerateOpacityMask;
	void * m_pvScan0;
};